package handlers

import (
	"github.com/gin-gonic/gin"
	"img-text-hub/models"
	"strconv"
)

func List(c *gin.Context) {
	page, _ := strconv.Atoi(c.Query("page"))
	size, _ := strconv.Atoi(c.Query("size"))
	offset := (page - 1) * size
	var img []models.Img
	models.DB.Offset(offset).Limit(size).Find(&img)
	var total int64
	models.DB.Model(models.Img{}).Count(&total)
	c.JSON(200, gin.H{
		"code":  200,
		"msg":   "查看成功",
		"data":  img,
		"total": total,
	})
	return
}
